#ifndef _MY_GAME_SCENE_H_
#define _MY_GAME_SCENE_H_
#include "cocos2d.h"
#include "AppDelegate.h"

#include <map>

using namespace cocos2d;
using namespace std;

namespace fireplane
{
	struct CollisionBox{
		string name;
		vector<CCPoint> _all_points;
	};

	class Player;
	class Camera;

	class GameScene : public cocos2d::CCLayer
	{
	public:
		GameScene();
		~GameScene();

		static GameScene* getGameScene();

		// Here's a difference. Method 'init' in cocos2d-x returns bool, instead of returning 'id' in cocos2d-iphone
		virtual bool init();  

		// there's no 'id' in cpp, so we recommand to return the exactly class pointer
		static cocos2d::CCScene* scene();


		static bool loadRes(void);
		// implement the "static node()" method manually
		LAYER_NODE_FUNC(GameScene);

		virtual bool ccTouchBegan(CCTouch *pTouch, CCEvent *pEvent);
		virtual void ccTouchMoved(CCTouch *pTouch, CCEvent *pEvent);
		virtual void ccTouchEnded(CCTouch *pTouch, CCEvent *pEvent);

		void update(float dt);
		void updateGameTime(float dt);

		CollisionBox* getCollisionBox(string name);

		void processCollision();
	private:
		void registerWithTouchDispatcher();
		void _do_gen_enemy_logic(float dt);

		bool _loadAllCollisionBox();
		void processBulletCollision();
		void processEnemyCollision2Player();
		Player* _hero;
		Camera* _cam;

		float _gametime;

		//////////////////////////////////////////////////////////////////////////
		// enemy
		float _gen_enemy_delay;
		int _gen_enemy_num;
		map<string,CollisionBox*> _all_collision_box;
		static GameScene* _s_GameScene;
	};
}

#endif